package com.book.domain;

public class HH {

	static int totalrecordnumber;
	int beginrecordnumber;
	int endrecordnumber;
	int beginpagenumber;
	int endpagenumber;
	int currentpagenumber;
	int totalpagenumber;
	int perpagerecordnumber;

	public int getTotalrecordnumber() {
		return totalrecordnumber;
	}

	public void setTotalrecordnumber(int totalrecordnumber) {
		this.totalrecordnumber = totalrecordnumber;
	}

	public int getBeginrecordnumber() {
		return beginrecordnumber;
	}

	public void setBeginrecordnumber(int beginrecordnumber) {
		this.beginrecordnumber = beginrecordnumber;
	}

	public int getEndrecordnumber() {
		return endrecordnumber;
	}

	public void setEndrecordnumber(int endrecordnumber) {
		this.endrecordnumber = endrecordnumber;
	}

	public int getBeginpagenumber() {
		return beginpagenumber;
	}

	public void setBeginpagenumber(int beginpagenumber) {
		this.beginpagenumber = beginpagenumber;
	}

	public int getEndpagenumber() {
		return endpagenumber;
	}

	public void setEndpagenumber(int endpagenumber) {
		this.endpagenumber = endpagenumber;
	}

	public int getCurrentpagenumber() {
		return currentpagenumber;
	}

	public void setCurrentpagenumber(int currentpagenumber) {
		this.currentpagenumber = currentpagenumber;
	}

	public int getTotalpagenumber() {
		return totalpagenumber;
	}

	public void setTotalpagenumber(int totalpagenumber) {
		this.totalpagenumber = totalpagenumber;
	}

	public int getPerpagerecordnumber() {
		return perpagerecordnumber;
	}

	public void setPerpagerecordnumber(int perpagerecordnumber) {
		this.perpagerecordnumber = perpagerecordnumber;
	}

	public static HH calculatepage(HH hh) {

		int totalrecordmunber = hh.getTotalrecordnumber();
		int currentpagenumber = hh.getCurrentpagenumber();
		int perpagerecordnumber = hh.getPerpagerecordnumber();
		int beginpage = 0;
		int totalpagenumber = 0;
		int endpage = 0;
		int endrecord = 0;
		int beginrecord = 0;
		if (totalrecordmunber % perpagerecordnumber == 0) {
			totalpagenumber = totalrecordmunber / perpagerecordnumber;
		} else {
			totalpagenumber = totalrecordmunber / perpagerecordnumber + 1;
		}

		if (currentpagenumber - 5 < 0) {
			beginpage = 1;
		} else {
			beginpage = currentpagenumber - 5;
		}
		if (currentpagenumber + 5 > totalpagenumber) {
			endpage = totalpagenumber;
		} else {
			endpage = currentpagenumber + 5;
		}
		beginrecord = (currentpagenumber - 1) * perpagerecordnumber + 1;
		if (currentpagenumber * perpagerecordnumber > totalrecordmunber) {
			endrecord = totalrecordmunber;

		} else {
			endrecord = currentpagenumber * perpagerecordnumber;

		}
       HH hhnew=new HH();
       hhnew.setBeginpagenumber(beginpage);
       hhnew.setBeginrecordnumber(beginrecord);
       hhnew.setCurrentpagenumber(currentpagenumber);
       hhnew.setEndpagenumber(endpage);
       hhnew.setEndrecordnumber(endrecord);
       hhnew.setTotalpagenumber(totalpagenumber);
       hhnew.setPerpagerecordnumber(perpagerecordnumber);
       hhnew.setTotalrecordnumber(totalrecordnumber);
		return hhnew;

	}

}
